(function (_super) {
    var io = ppt.io;

    function PersonalInfo() {
        PersonalInfo.super(this);

        this.role = null;

        this.init();
    }
    Laya.class(PersonalInfo, "Alert.PersonalInfo", _super);
    var _proto = PersonalInfo.prototype;
    _proto.destroy = function () {
        _super.prototype.destroy.call(this, true);

        io.unregister("game::enter", this.update);
        this.role = null;
    }
    _proto.init = function () {
        Laya.timer.callLater(this, function () {
            io.register("game::enter", this, this.update);
            io.emit({"cmd" : "game::enter"});
        });

        this.btnClose.on(Laya.Event.CLICK, this, this.destroy);
    }

    _proto.update = function (data) {
        this.avatar.skin = data.avatar == "" ? USER_DEFAULT_AVATAR : data.avatar;
        this.nickName.text = utils.cutStr(data.name, 10);
        this.level.text = "lv:" + data.lvl;
        this.userId.text = "[ID:" + userId + "]";
        this.roleName.text = data.roleName;
        this.expNum.text = data.exp + "/" + data.nextExp;

        var progress = data.exp / data.nextExp;
        if(data.exp==0){
            this.levelNum.visible = false;
        }else{
            this.levelNum.visible = true;
            this.levelNum.width = progress * 320;
        }

        if(this.role){
            this.role.destroy(true);
            this.role = null;
        }
        var role = utils.createSkeleton(ROLE_NORMAL_SKIN_PATH + data.roleId);
            role.pos(this.roleWrap.width / 2, this.roleWrap.height / 2);
            role.play(0, true);

        this.role = role;
        this.roleWrap.addChild(role);
    }
})(ui.Alert.PersonalInfoUI);